//
//  UINavigationItem+Fixios7.m
//  Koina
//
//  Created by welldone on 13-12-23.
//  Copyright (c) 2013年 net.koina. All rights reserved.
//

#import "UINavigationItem+Fixios7.h"
#import "config.h"



@implementation UINavigationItem (Fixios7)


- (void)setLeftBarButtonItem:(UIBarButtonItem *)_leftBarButtonItem{
    
    UIBarButtonItem *spaceButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    
    if (isIOS7) {
         spaceButtonItem.width = -16;
    }else{
         spaceButtonItem.width = 0;
    }
   
    if (_leftBarButtonItem){
        [self setLeftBarButtonItems:@[spaceButtonItem, _leftBarButtonItem]];
    }  else {
        [self setLeftBarButtonItems:@[spaceButtonItem]];
    }

}

- (void)setRightBarButtonItem:(UIBarButtonItem *)_rightBarButtonItem{
    
    
    UIBarButtonItem *spaceButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    
    if (isIOS7) {
        spaceButtonItem.width = -16;
    }else{
        spaceButtonItem.width = 0;
    }
    
    if (_rightBarButtonItem.customView==nil) {//是系统的，不是我们定制的，因为我定制的都放在CustomVeiw里
        spaceButtonItem.width = 0;
    }
    
    if (_rightBarButtonItem) {
        [self setRightBarButtonItems:@[spaceButtonItem, _rightBarButtonItem]];
    } else   {
        [self setRightBarButtonItems:@[spaceButtonItem]];
    }

}



@end
